#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>

//https://www.nowcoder.com/practice/7299c12e6abb437c87ad3e712383ff84?tpId=37&&tqId=21279&rp=1&ru=/ta/huawei&qru=/ta/huawei/question-ranking

bool isPerfectNum(int num) {
    int sum = 1;
    for (int i = 2; i < num; i++) {
        if (num % i == 0) {
            sum += i;
        }
    }
    if (sum == num) {
        return true;
    } else {
        return false;
    }
}

int main() {
    int input = 0;
    int count = 0;
    scanf("%d", &input);
    for (int i = 2; i < input; i++) {
        if (isPerfectNum(i)) {
            count++;
        }
    }
    printf("%d", count);
    return 0;
}